<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

//http://www.laravel.me/id/123
Route::get('id/{id}', function ($id) {
    return 'id: '.$id;
});

Route::get('/aaa', function () {
    return 'Hello Worldsss';
});
Route::post('/posts', function () {
    return 'post';
});


//控制器路由
Route::get('test', 'TestController@index');

//控制器路由 后台模块
// Route::get('houtai/index', 'Admin\IndexController@index');
// Route::get('houtai/login', 'Admin\IndexController@login');
//前缀都是admin
Route::group(['prefix' => 'houtai','namespace' => 'Admin' ,'middleware' => ['web','checkAdminLogin']], function () {
   Route::get('index', 'IndexController@index');
   // Route::get('login', 'IndexController@login');
});


//命名控制器路由 as是别名
Route::get('aaa', ['as' => 'test', function(){
    echo route('test') . '<br>';  //http://www.laravel.me/aaa
	return "命名路由";
}]);

//命名控制器路由 
// Route::get('bbb', [
// 	'as' => 'test' , 'uses' => 'TestController@index'
// ]);

// Route::get('bbb','TestController@index')->name('test');

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
//middleware ---中间件(通过中间层保护)
//HTTP 中间件提供了为过滤进入应用的 HTTP 请求提供了一套便利的机制。
//例如，Laravel 内置了一个中间件来验证用户是否经过授权，如果用户没有经过授权，
//中间件会将用户重定向到登录页面，否则如果用户经过授权，
//中间件就会允许请求继续往前进入下一步操作。
 //HTTP会话状态，CSRF保护  (中间件)起到过滤的作用  web和checkAdminLogin都是中间键
Route::group(['middleware' => ['web']], function () {

   //进入登录页面验证时将session赋值
   Route::get('houtai/login', 'Admin\IndexController@login');



   Route::get('/', function () {
	session(['aa'=> 123]);
    return view('welcome');
   });

   Route::get('/eee', function () {
    return '得到了aa的值为' . session('aa');
});

});
